const { resolve } = require('path')

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import styleImport from 'vite-plugin-style-import'

export default defineConfig({

  base: "./", // 打包文件 html 中 css 和 js 的引入基础路径，默认 '/'

  resolve: {
    alias: {
      '/@': resolve(__dirname, 'src'),
      '/components': resolve(__dirname, 'src/components'),
      '/plugin': resolve(__dirname, 'src/plugin'),
    },
  },
  plugins: [
    // ----------- ElementPlus 按需引入 ------------------
    vue(),
    styleImport({
      libs: [
        {
          libraryName: 'element-plus',
          esModule: true,
          ensureStyleFile: true,
          resolveStyle: (name) => {
            return `element-plus/lib/theme-chalk/${name}.css`;
          },
          resolveComponent: (name) => {
            return `element-plus/lib/${name}`;
          },
        }
      ]
    })
    // ----------- ElementPlus 按需引入 ------------------
  ]
})